<?php

$ctype='htm';
if(isset($_GET['ctype']))$ctype=$_GET['ctype'];

static $mimes = array(
    'svg' => 'image/svg+xml',
    'xml' => 'text/xml',
);

if(isset($mimes[$ctype]))
	header("Content-type: ".$mimes[$format].'; charset=utf-8');
else
	header("Content-type: text/html; charset=utf-8");


$xsl=$_GET['xsl'];
$xml=$_GET['xml'];

require_once('apm-conf.inc');

$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);

$xslDoc = new DOMDocument();
$proc = new XSLTProcessor();

$xslDoc->load($xsl);
$proc->importStylesheet($xslDoc);

//set parameters for xslt processor
foreach ($_GET as $key => $value){
	if( preg_match ( '/^xs[A-Z].*/', $key) ) {
		$proc->setParameter('', $key, $value);
	}
}

echo $proc->transformToXML($xmlDoc);

